
#include "stm8l15x.h"


#include "PublicSet1.h"

#include "extern1.h"

#include "frozefun.h"
#include "froze_eventcleardata.h"

extern strRamData RamData;


void
froze_initeventclearbuf (void)
{
  Queue_init (_FROZE_EVENT_CLEAR_);
}

void
froze_eventclear (void)
{
  struct STEEVNTCLEARRECORD s;

  s.lEventTime = RamData.RTCTime;
  s.l645data = *(u32 *) (ComData + 6);
  s.lWriteCode = RamData.WriterCode;
  Queue_PutUnit (_FROZE_EVENT_CLEAR_, (u8 *) & s);
}


@inline void
froze_eventclearread (struct STEEVNTCLEARRECORD *s,
		      struct STFROZE_COMM_EVENTCLEAR *d)
{
  FillRam ((u8 *) d, 0, sizeof (struct STFROZE_COMM_EVENTCLEAR));
  if (s)
    {
      GetCntTime (d->csEventTime, s->lEventTime);
      d->lWriteCode = s->lWriteCode;
      d->l645data = s->l645data;
    }


}

u32
RxClrEventRcd (u32 Code)
{
  struct STFROZE_COMM_EVENTCLEAR d;
  u8 Cnt;
  u16 Addr;
  u8 Type;
  struct STEEVNTCLEARRECORD *s = (struct STEEVNTCLEARRECORD *) RamData.pBase;
  u8 cOffset = ((Code & 0xFF) - 1);


  s =
    (struct STEEVNTCLEARRECORD *) GetFrozeStart (_FROZE_EVENT_CLEAR_,
						 (cOffset - 1));
  froze_eventclearread (s, (struct STFROZE_COMM_EVENTCLEAR *) (ComData + 6));
  RamData.pChar += sizeof (struct STFROZE_COMM_EVENTCLEAR);
  return 0;
}
